<?php
/**
 * Created by PhpStorm.
 * User: dust2
 * Date: 15-1-2
 * Time: 下午3:07
 */

/**
 * 订单－商品关联表播种
 * Class OrderProductTableSeeder
 */
class OrderProductTableSeeder extends Seeder
{
    public function run()
    {
        DB::table('order_product')->delete();

        DB::table('order_product')->insert(['order_id' => 1, 'product_id' => 1, 'count' => '10', 'created_at' => $this->getTime(), 'updated_at' => $this->getTime()]);
        DB::table('order_product')->insert(['order_id' => 1, 'product_id' => 2, 'count' => '20', 'created_at' => $this->getTime(), 'updated_at' => $this->getTime()]);
        DB::table('order_product')->insert(['order_id' => 2, 'product_id' => 1, 'count' => '10', 'created_at' => $this->getTime(), 'updated_at' => $this->getTime()]);
        DB::table('order_product')->insert(['order_id' => 2, 'product_id' => 3, 'count' => '30', 'created_at' => $this->getTime(), 'updated_at' => $this->getTime()]);
    }

    /**
     * 获取固定格式时间
     * @return bool|string
     */
    private function getTime()
    {
        return date('Y-m-d h:m:s');
    }
}